package com.atguigu.tree;

/**
 * 线索化二叉树
 */
public class ThreadBinaryTreeDemo {
    private ThreadBinaryTree root = null;

    //定义一个临时的前驱节点
    private ThreadBinaryTree pre = null;

    public void makeThread(ThreadBinaryTree node){
       if (node == null){
           return;
       }

       if (node.getLeftNode() == null){
           node.setLeftNode(pre);
           node.setLeftType(1);
       }


    }
    public static void main(String[] args) {

    }


}

class ThreadBinaryTree{
    private int num;
    private String name;
    private ThreadBinaryTree leftNode;
    private ThreadBinaryTree rightNode;
    //定义左子树类型，0代表是左子节点，1代表是前驱节点
    private int leftType;
    //定义右子树类型，0代表是右子节点，1代表是后继节点
    private int rightType;



    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ThreadBinaryTree getLeftNode() {
        return leftNode;
    }

    public void setLeftNode(ThreadBinaryTree leftNode) {
        this.leftNode = leftNode;
    }

    public ThreadBinaryTree getRightNode() {
        return rightNode;
    }

    public void setRightNode(ThreadBinaryTree rightNode) {
        this.rightNode = rightNode;
    }

    public int getLeftType() {
        return leftType;
    }

    public void setLeftType(int leftType) {
        this.leftType = leftType;
    }

    public int getRightType() {
        return rightType;
    }

    public void setRightType(int rightType) {
        this.rightType = rightType;
    }

    @Override
    public String toString() {
        return "ThreadBinaryTree{" +
                "num=" + num +
                ", name='" + name + '\'' +
                '}';
    }
}